CFLAGS = -I. -DJSMN_PARENT_LINKS -DJSMN_STATIC

CC = gcc
OBJSDIR = ./build

.PHONY: all clean

TARGETS = main
OBJS = ./build/jsmn_util.o ./build/main.o

all : $(TARGETS)

main : $(OBJS)
	${CC} $^ -g -o $@

./build/jsmn.o : ./jsmn.h
	${CC} -g -c $^ -o $@ ${CFLAGS}

./build/jsmn_util.o : ./jsmn_util.c
	@if [ ! -d $(OBJSDIR) ]; then \
		mkdir -p $(OBJSDIR); \
	fi
	${CC} -g -c $^ -o $@ ${CFLAGS}

./build/main.o : main.c
	${CC} -g -c $^ -o $@ ${CFLAGS}

clean:
	$(RM) ./*.exe
	$(RM) $(TARGETS)
	$(RM) $(OBJS)